<?php 
//data_guru_page.php

/**
 * Fungsi ini berguna untuk menampilkan form guru pada admin WordPress
 */

function data_guru_page(){
	$crud = $_REQUEST['crud'];

	switch ($crud){
		case "read": read_data_guru();break;
		case "create": create_data_guru();break;
		case "update": update_data_guru();break;
		case "delete": delete_data_guru();break;
		default: panel_data_guru();break;
		case "form": form_update_data_guru();break;
		case "telah": telah_update_data_guru();break;
	}
	//echo "<pre>"; print_r($GLOBALS); echo "</pre>";

}


function panel_data_guru(){
	?><h2>Menu :</h2>
	<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=read">Lihat</a> Data Guru</h3>
	<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=create">Tambah</a> Data Guru Baru</h3>
	<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=update">Ubah</a> Data Guru</h3>
	<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=delete">Hapus</a> Data Guru</h3>
	
	<?
}


function delete_data_guru(){
	global $wpdb;
	//kalau sudah ada $id_guru yang ingin di delete, maka hapus
	if(trim($_REQUEST['id_guru']!='')){
		//hapus dari database
		$id_guru = $_REQUEST['id_guru'];
		$wpdb->query("DELETE from guru where id_guru='$id_guru';");
	}
	
	//tampilkan semua guru:
	$fivesdrafts = $wpdb->get_results("	SELECT * FROM guru;");
	echo "<table class=\"wp-list-table widefat fixed pages\"><tr>
	<th class='manage-column column-cb check-column'>No</th>
	<th class='manage-column column-cb check-column'>NIP</th>
	<th class='manage-column column-cb check-column'>Nama Guru</th>
	<th class='manage-column column-cb check-column'>Jenis Kelamin</th>
	<th class='manage-column column-cb check-column'>Alamat</th>
	<th class='manage-column column-cb check-column'>Status</th>
	<th class='manage-column column-cb check-column'>Golongan</th>
	<th class='manage-column column-cb check-column'>Jabatan</th>
	<th class='manage-column column-cb check-column'>Pendidikan Terakhir</th>
	<th class='manage-column column-cb check-column'>semester</th>
	<th class='manage-column column-cb check-column'>Tahun Ajaran</th>
	<th class='manage-column column-cb check-column'>Hapus</th>
	</tr>";

	$L=1;
	foreach ( $fivesdrafts as $guru ) 
	{
		echo "<tr class='hentry alternate'><td>".$L++ . " </td>
		<td>" .$guru->nip .  " </td>
		<td>". $guru->nama_guru. "</td>
		<td>" .$guru->jenis_kelamin .  " </td>
		<td>" .$guru->alamat .  " </td>
		<td>" .$guru->status .  " </td>
		<td>" .$guru->golongan .  " </td>
		<td>" .$guru->jabatan .  " </td>
		<td>" .$guru->pendidikan_terakhir . "</td>
		<td>" .$guru->semester . "</td>
		<td>" .$guru->tahun_ajaran . "</td>
		<td>"."<a href=\"".admin_url('admin.php')."?page=".$_REQUEST['page']."&crud=delete&id_guru=". $guru->id_guru ."\">Hapus</a></td></tr>";
			
	}
	echo "</table>";
	?>
	<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=panel">Kembali</a></h3>
	<?
}

function create_data_guru(){
	global $wpdb;
	?><div class="wrap">
    <div id="icon-users" class="icon32"></div>
    <h2>Data Guru</h2>
    Lengkapi data guru di bawah ini :
	
	<?
  
	//check if option is set before saving
    if ( isset( $_POST['nama_guru'] ) ) {
        //retrieve the option value from the form
		$nip =  $_POST['nip'] ;
		$nama_guru =  $_POST['nama_guru'] ;
		$jenis_kelamin =  $_POST['jenis_kelamin'] ;
		$alamat =  $_POST['alamat'] ;
        $status =  $_POST['status'] ;
		$golongan =  $_POST['golongan'] ;
		$jabatan =  $_POST['jabatan'] ;
		$pendidikan_terakhir =  $_POST['pendidikan_terakhir'] ;
		$no_hp =  $_POST['no_hp'] ;
		$semester =  $_POST['semester'] ;
		$tahun_ajaran =  $_POST['tahun_ajaran'] ;
		$id_sekolah =  $_POST['id_sekolah'] ;
		$id_guru=0;
		$wpdb->query("INSERT INTO `guru` (
		`id_guru` ,
		`nip` ,
		`nama_guru` ,
		`jenis_kelamin` ,
		`alamat` ,
		`status` ,
		`golongan` ,
		`jabatan` ,
		`pendidikan_terakhir` ,
		`no_hp`,
		`semester`,
		`tahun_ajaran`,
		`id_sekolah`
		)
		VALUES ('$ID_Guru', '$nip', '$nama_guru', '$jenis_kelamin', '$alamat', '$status', '$golongan', '$jabatan', '$pendidikan_terakhir', '$no_hp', '$semester', '$tahun_ajaran', '$id_sekolah');");

		echo "<h2>Sukses menyimpan data guru $NAMA_Guru ke database</h2>";

	}
	?> 
	<form id="form1" name="form1" method="post" action="">
	<table class="form-table" >
			<!--tr>
			  <th><label for="id_guru">ID Guru</label></th>
			  <td>
				<input type="text" id="id_guru" name="id_guru" value="<?php echo $id_guru;?>" class="regular-text">
			  </td>
			</tr-->
    <tr>
      <th><label for="nip">Nomor Induk Pegawai</label></th>
      <td>
        <input type="text" id="nip" name="nip" value="<?php echo $nip;?>" class="regular-text">
        <br />
      </td>
    </tr>
    
    <tr>
      <th><label for="nama_guru">Nama Guru</label></th>
      <td>
        <input type="text" id="nama_guru" name="nama_guru" value="<?php echo $nama_guru;?>" class="regular-text">
        <br />
      </td>
    </tr>

	<tr>
	<th><label for="jenis_kelamin">Jenis Kelamin</label></th>
	<td>
    <input name="jenis_kelamin" type="radio" value="PRIA" />PRIA
    <input name="jenis_kelamin" type="radio" value="WANITA" />WANITA
      </td>
    </tr>
    
    <tr>
      <th><label for="alamat">Alamat</label></th>
      <td>
	    <textarea name="alamat" id="alamat" rows="5" cols="30"><?php echo $alamat;?></textarea>
        <br />
      </td>
    </tr>

	<tr>
      <th><label for="status">Status</label></th>
      <td>
        <!-- <input type="text" id="status" name="status" value="<?php echo $status;?>" class="regular-text"> -->
        <SELECT NAME="status" ID="status">
          <OPTION VALUE=""></OPTION>
          <OPTION VALUE="PNS" <?php selected( $status, 'PNS' ); ?>>PNS</OPTION>
          <OPTION VALUE="Kontrak" <?php selected( $status, 'Kontrak' ); ?>>Kontrak</OPTION>
          <OPTION VALUE="Lainnya" <?php selected( $status, 'Lainnya' ); ?>>Lainnya</OPTION>
        </SELECT>
        <br />
      </td>
    </tr>
    <tr>
      <th><label for="golongan">Golongan</label></th>
      <td>
        <input type="text" id="golongan" name="golongan" value="<?php echo $golongan;?>" class="regular-text">
        <br />
      </td>
    </tr>
    <tr>
      <th><label for="jabatan">Jabatan</label></th>
      <td>
        <input type="text" id="jabatan" name="jabatan" value="<?php echo $jabatan;?>" class="regular-text">
        <br />
      </td>
    </tr>
	<tr>
      <th><label for="pendidikan_terakhir">Pendidikan Terakhir</label></th>
      <td>
        <!-- <input type="text" id="pendidikan_terakhir" name="pendidikan_terakhir" value="<?php echo $pendidikan_terakhir;?>" class="regular-text"> -->
        <SELECT NAME="pendidikan_terakhir" ID="pendidikan_terakhir">
          <OPTION VALUE=""></OPTION>
          <OPTION VALUE="SMA / SEDERAJAT" <?php selected( $pendidikan_terakhir, 'SMA / SEDERAJAT' ); ?>>SMA / SEDERAJAT</OPTION>
          <OPTION VALUE="DIPLOMA 3" <?php selected( $pendidikan_terakhir, 'DIPLOMA 3' ); ?>>DIPLOMA 3</OPTION>
          <OPTION VALUE="DIPLOMA 4 / STRATA 1" <?php selected( $pendidikan_terakhir, 'DIPLOMA 4 / STRATA 1' ); ?>>DIPLOMA 4 / STRATA 1</OPTION>
          <OPTION VALUE="STRATA 2" <?php selected( $pendidikan_terakhir, 'STRATA 2' ); ?>>STRATA 2</OPTION>
          <OPTION VALUE="STRATA 3" <?php selected( $pendidikan_terakhir, 'STRATA 3' ); ?>>STRATA 3</OPTION>
          <OPTION VALUE="Lainnya" <?php selected( $pendidikan_terakhir, 'Lainnya' ); ?>>Lainnya</OPTION>
        </SELECT>
        <br />
      </td>
    </tr>
	<tr>
      <th><label for="no_hp">No Hp</label></th>
      <td>
        <input type="text" id="no_hp" name="no_hp" value="<?php echo $no_hp;?>" class="regular-text">
        <br />
      </td>
	  </tr>
	  <tr>
      <th><label for="semester">Semester</label></th>
      <td>
        <!-- <input type="text" id="semester" name="semester" value="<?php echo $semester;?>" class="regular-text"> -->
        <SELECT NAME="semester" ID="semester">
          <OPTION VALUE=""></OPTION>
          <OPTION VALUE="I" <?php selected( $semester, 'I' ); ?>>I</OPTION>
          <OPTION VALUE="II" <?php selected( $semester, '2' ); ?>>II</OPTION>
          <OPTION VALUE="III" <?php selected( $semester, 'III' ); ?>>III</OPTION>
		  <OPTION VALUE="IV" <?php selected( $semester, 'IV' ); ?>>IV</OPTION>
          <OPTION VALUE="V" <?php selected( $semester, 'V' ); ?>>V</OPTION>
          <OPTION VALUE="VI" <?php selected( $semester, 'VI' ); ?>>VI</OPTION>
        </SELECT>
        <br />
      </td>
    </tr>
	<tr>
      <th><label for="tahun_ajaran">Tahun Ajaran</label></th>
      <td>
        <!-- <input type="text" id="tahun_ajaran" name="tahun_ajaran" value="<?php echo $tahun_ajaran;?>" class="regular-text"> -->
        <SELECT NAME="tahun_ajaran" ID="tahun_ajaran">
          <OPTION VALUE=""></OPTION>
          <OPTION VALUE="2005" <?php selected( $tahun_ajaran, '2005' ); ?>>2005</OPTION>
          <OPTION VALUE="2006" <?php selected( $tahun_ajaran, '2006' ); ?>>2006</OPTION>
          <OPTION VALUE="2007" <?php selected( $tahun_ajaran, '2007' ); ?>>2007</OPTION>
		  <OPTION VALUE="2008" <?php selected( $tahun_ajaran, '2008' ); ?>>2008</OPTION>
          <OPTION VALUE="2009" <?php selected( $tahun_ajaran, '2009' ); ?>>2009</OPTION>
          <OPTION VALUE="2010" <?php selected( $tahun_ajaran, '2010' ); ?>>2010</OPTION>
        </SELECT>
        <br />
      </td>
    </tr>
	  
	  <tr>
		  <th><label for="id_sekolah">Nama Sekolah</label></th>
		  <td>
			<!-- 
			SELECT id_sekolah, nama_sekolah FROM `sekolah`

			-->
			<?php 
			global $wpdb;
			$sekolah = $wpdb->get_results("SELECT id_sekolah, nama_sekolah FROM `sekolah`");
			//print_r($sekolah);
			?>
			<SELECT NAME="id_sekolah" ID="id_sekolah">
			  <OPTION VALUE=""></OPTION>
			<?php
			foreach ( $sekolah as $sekolah_detail ) 
			{
				echo "<OPTION VALUE=\"$sekolah_detail->id_sekolah;\" ". selected($id_sekolah,$sekolah_detail->id_sekolah).">$sekolah_detail->nama_sekolah;</OPTION>";
			}
			?>
			</SELECT>	  
		  
			<br />
			<span class="description">Pilih Nama Sekolah ! </span>
			</select>
		  </td>
		  </tr>
	  </table><br>
	<input type=submit name=submit value=Daftar>&nbsp;&nbsp;
	<input type=reset name=reset value=Batal>
	</form>
		<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=panel">Kembali</a></h3>
	<?php
}

function read_data_guru(){
	echo "Daftar guru yang ada di Kabupaten Kampar adalah sebagai berikut :";
	echo ("<br>");
	echo ("<br>");
	
	//print_r($_POST);
	global $wpdb;
	// $hasilcari = Array();
	// $hasilcari = $wpdb->get_results("SELECT * FROM guru WHERE nama_guru LIKE '%$nama_guru%'");
	// foreach($hasilcari as $guru){
		// echo "<a href=\"admin.php?page=".$_REQUEST['page']."&crud=update&id_guru=".$guru->id_guru."\">". $guru->nama_guru. "</a><br/>";
	// }
	// echo ("<br>");
	// echo ("<br>");
	
	$fivesdrafts = $wpdb->get_results("	SELECT * FROM guru;");
	echo "<table class=\"wp-list-table widefat fixed pages\">
	<tr><th class='manage-column column-cb check-column'>No</th>
	<th class='manage-column column-cb check-column'>NIP</th>
	<th class='manage-column column-cb check-column'>Nama Guru</th>
	<th class='manage-column column-cb check-column'>Jenis Kelamin</th>
	<th class='manage-column column-cb check-column'>Alamat</th>
	<th class='manage-column column-cb check-column'>Status</th>
	<th class='manage-column column-cb check-column'>Golongan</th>
	<th class='manage-column column-cb check-column'>Jabatan</th>
	<th class='manage-column column-cb check-column'>Pendidikan Terakhir</th>
	<th class='manage-column column-cb check-column'>semester</th>
	<th class='manage-column column-cb check-column'>Tahun Ajaran</th>
	</tr>";

	$L=1;
	foreach ( $fivesdrafts as $fivesdraft ) 
	{
		echo "<tr class='hentry alternate'><td>".$L++ . " </td>
		<td>" .$fivesdraft->nip .  " </td>
		<td>". $fivesdraft->nama_guru. "</td>
		<td>" .$fivesdraft->jenis_kelamin .  " </td>
		<td>" .$fivesdraft->alamat .  " </td>
		<td>" .$fivesdraft->status .  " </td>
		<td>" .$fivesdraft->golongan .  " </td>
		<td>" .$fivesdraft->jabatan .  " </td>
		<td>" .$fivesdraft->pendidikan_terakhir . "</td>
		<td>" .$fivesdraft->semester . "</td>
		<td>" .$fivesdraft->tahun_ajaran . "</td>
		</tr>";
			
	}
	echo "</table>";
	?>
	<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=panel">Kembali</a></h3>
	<?
}

function update_data_guru(){
	$nama_guru = $_POST['nama_guru'];
	?>
	<form id="form1" name="form1" method="post" action="">
		<table class="form-table" >
		<tr>
		  <th><label for="nama_guru">Masukkan Nama guru yang akan di UPDATE !</label></th>
		  <td>
			<input type="text" id="nama_guru" name="nama_guru" value="<?php echo $nama_guru;?>" class="regular-text">
			<br />
		  </td>
		</tr>		
		</table>
		<br>
		<input type="Submit" value="Cari!" />
	</form>
	<?
	echo ("<br>");
	//kalau user mengklik tombol Cari, maka cari di database
    // if ( isset( $_POST['nama_guru'] ) ) {
		// echo "Anda mencari guru ini: " . $nama_guru."<br/>";
	// }
	
	//print_r($_POST);
	global $wpdb;
	$hasilcari = Array();
	$hasilcari = $wpdb->get_results("SELECT * FROM guru WHERE nama_guru LIKE '%$nama_guru%'");
	foreach($hasilcari as $guru){
		echo "<a href=\"admin.php?page=".$_REQUEST['page']."&crud=form&id_guru=".$guru->id_guru."\">". $guru->nama_guru. "</a><br/>";
	}
	echo ("<br>");
	echo ("<br>");
	?>
	<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=panel">Kembali</a></h3>
	<?
	
}
	
function telah_update_data_guru(){
	//echo "Update data guru";
	if($_POST['submit']=="Update"){
		echo "Anda telah <b>BERHASIL</b> update data guru";
		echo ("<br>");
		echo ("<br>");
		global $wpdb;
		$nip =  $_POST['nip'] ;
		$nama_guru =  $_POST['nama_guru'] ;
		$jenis_kelamin =  $_POST['jenis_kelamin'] ;
		$alamat =  $_POST['alamat'] ;
		$status =  $_POST['status'] ;
		$golongan =  $_POST['golongan'] ;
		$jabatan =  $_POST['jabatan'] ;
		$pendidikan_terakhir =  $_POST['pendidikan_terakhir'] ;
		$no_hp =  $_POST['no_hp'] ;
		$semester =  $_POST['semester'] ;
		$tahun_ajaran =  $_POST['tahun_ajaran'] ;
		$id_sekolah =  $_POST['id_sekolah'] ;
		$id_guru = $_POST['id_guru'];
		$SQL = "UPDATE `guru` set
		`nip` ='$nip',
		`nama_guru`= '$nama_guru',
		`jenis_kelamin` = '$jenis_kelamin',
		`alamat` = '$alamat',
		`status` = '$status',
		`golongan` = '$golongan',
		`jabatan` = '$jabatan',
		`pendidikan_terakhir` = '$pendidikan_terakhir',
		`no_hp` ='$no_hp',
		`semester` ='$semester',
		`tahun_ajaran` ='$tahun_ajaran',
		`id_sekolah` ='$id_sekolah'
		WHERE 
		`id_guru` = '$id_guru' ;";
		$wpdb->query($SQL);
		echo $SQL;
		?>
		<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=panel">Kembali</a></h3>
		<?
	}
	
	echo "<!--pre>";
	print_r($_GET);
	print_r($_POST);
	print_r($_REQUEST);
	echo "</pre-->";
}

function form_update_data_guru(){
	if(isset($_GET['id_guru']) || isset($_POST['id_guru'])){
		//echo "ID gurunya adalah: " .$_GET['id_guru'];
		$id_guru = $_GET['id_guru'];
		global $wpdb;
		$hasilcari = $wpdb->get_results("SELECT * FROM guru WHERE id_guru = '$id_guru'");
		foreach($hasilcari as $guru){
			?>
			<form id="form1" name="form1" method="post" action="admin.php?page=<?=$_REQUEST['page']?>&crud=telah&id_guru="<? echo $guru->id_guru; ?>">
				<table class="form-table" >
				<input type=hidden name=id_guru value="<?=$guru->id_guru?>" />
    
			<tr>
			  <th><label for="nip">Nomor Induk Pegawai</label></th>
			  <td>
				<input type="text" id="nip" name="nip" value="<?php echo $guru->nip;?>" class="regular-text">
				<br />
			  </td>
			</tr>
			
			<tr>
			  <th><label for="nama_guru">Nama Guru</label></th>
			  <td>
				<input type="text" id="nama_guru" name="nama_guru" value="<?php echo $guru->nama_guru;?>" class="regular-text">
				<br />
			  </td>
			</tr>

			<tr>
			<th><label for="jenis_kelamin">Jenis Kelamin</label></th>
			<td>
			<input name="jenis_kelamin" type="radio" value="PRIA" />PRIA
			<input name="jenis_kelamin" type="radio" value="WANITA" />WANITA
			  </td>
			</tr>
			
			<tr>
			  <th><label for="alamat">Alamat</label></th>
			  <td>
				<textarea name="alamat" id="alamat" rows="5" cols="30"><?php echo $guru->alamat;?></textarea>
				<br />
			  </td>
			</tr>

			<tr>
			  <th><label for="status">Status</label></th>
			  <td>
				<!-- <input type="text" id="status" name="status" value="<?php echo $guru->status;?>" class="regular-text"> -->
				<SELECT NAME="status" ID="status">
				  <OPTION VALUE=""></OPTION>
				  <OPTION VALUE="PNS" <?php selected( $guru->status, 'PNS' ); ?>>PNS</OPTION>
				  <OPTION VALUE="Kontrak" <?php selected( $guru->status, 'Kontrak' ); ?>>Kontrak</OPTION>
				  <OPTION VALUE="Lainnya" <?php selected( $guru->status, 'Lainnya' ); ?>>Lainnya</OPTION>
				</SELECT>
				<br />
			  </td>
			</tr>
			<tr>
			  <th><label for="golongan">Golongan</label></th>
			  <td>
				<input type="text" id="golongan" name="golongan" value="<?php echo $guru->golongan;?>" class="regular-text">
				<br />
			  </td>
			</tr>
			<tr>
			  <th><label for="jabatan">Jabatan</label></th>
			  <td>
				<input type="text" id="jabatan" name="jabatan" value="<?php echo $guru->jabatan;?>" class="regular-text">
				<br />
			  </td>
			</tr>
			<tr>
			  <th><label for="pendidikan_terakhir">Pendidikan Terakhir</label></th>
			  <td>
				<!-- <input type="text" id="pendidikan_terakhir" name="pendidikan_terakhir" value="<?php echo $guru->pendidikan_terakhir;?>" class="regular-text"> -->
				<SELECT NAME="pendidikan_terakhir" ID="pendidikan_terakhir">
				  <OPTION VALUE=""></OPTION>
				  <OPTION VALUE="SMA / SEDERAJAT" <?php selected( $guru->pendidikan_terakhir, 'SMA / SEDERAJAT' ); ?>>SMA / SEDERAJAT</OPTION>
				  <OPTION VALUE="DIPLOMA 3" <?php selected( $guru->pendidikan_terakhir, 'DIPLOMA 3' ); ?>>DIPLOMA 3</OPTION>
				  <OPTION VALUE="DIPLOMA 4 / STRATA 1" <?php selected( $guru->pendidikan_terakhir, 'DIPLOMA 4 / STRATA 1' ); ?>>DIPLOMA 4 / STRATA 1</OPTION>
				  <OPTION VALUE="STRATA 2" <?php selected( $guru->pendidikan_terakhir, 'STRATA 2' ); ?>>STRATA 2</OPTION>
				  <OPTION VALUE="STRATA 3" <?php selected( $guru->pendidikan_terakhir, 'STRATA 3' ); ?>>STRATA 3</OPTION>
				  <OPTION VALUE="Lainnya" <?php selected( $guru->pendidikan_terakhir, 'Lainnya' ); ?>>Lainnya</OPTION>
				</SELECT>
				<br />
			  </td>
			</tr>
			<tr>
			  <th><label for="no_hp">No Hp</label></th>
			  <td>
				<input type="text" id="no_hp" name="no_hp" value="<?php echo $guru->no_hp;?>" class="regular-text">
				<br />
			  </td>
			  </tr>
		<th><label for="semester">Semester</label></th>
		  <td>
			<!-- <input type="text" id="semester" name="semester" value="<?php echo $guru->semester;?>" class="regular-text"> -->
			<SELECT NAME="semester" ID="semester">
			  <OPTION VALUE=""></OPTION>
			  <OPTION VALUE="I" <?php selected( $guru->semester, 'I' ); ?>>I</OPTION>
			  <OPTION VALUE="II" <?php selected( $guru->semester, '2' ); ?>>II</OPTION>
			  <OPTION VALUE="III" <?php selected( $guru->semester, 'III' ); ?>>III</OPTION>
			  <OPTION VALUE="IV" <?php selected( $guru->semester, 'IV' ); ?>>IV</OPTION>
			  <OPTION VALUE="V" <?php selected( $guru->semester, 'V' ); ?>>V</OPTION>
			  <OPTION VALUE="VI" <?php selected( $guru->semester, 'VI' ); ?>>VI</OPTION>
			</SELECT>
			<br />
		  </td>
		</tr>
		<tr>
		  <th><label for="tahun_ajaran">Tahun Ajaran</label></th>
		  <td>
			<!-- <input type="text" id="tahun_ajaran" name="tahun_ajaran" value="<?php echo $guru->tahun_ajaran;?>" class="regular-text"> -->
			<SELECT NAME="tahun_ajaran" ID="tahun_ajaran">
			  <OPTION VALUE=""></OPTION>
			  <OPTION VALUE="2005" <?php selected( $guru->tahun_ajaran, '2005' ); ?>>2005</OPTION>
			  <OPTION VALUE="2006" <?php selected( $guru->tahun_ajaran, '2006' ); ?>>2006</OPTION>
			  <OPTION VALUE="2007" <?php selected( $guru->tahun_ajaran, '2007' ); ?>>2007</OPTION>
			  <OPTION VALUE="2008" <?php selected( $guru->tahun_ajaran, '2008' ); ?>>2008</OPTION>
			  <OPTION VALUE="2009" <?php selected( $guru->tahun_ajaran, '2009' ); ?>>2009</OPTION>
			  <OPTION VALUE="2010" <?php selected( $guru->tahun_ajaran, '2010' ); ?>>2010</OPTION>
			</SELECT>
			<br />
		  </td>
		</tr>
			  <th><label for="id_sekolah">Nama Sekolah</label></th>
			  <td>
				<!-- 
				SELECT id_sekolah, nama_sekolah FROM `sekolah`

				-->
				<?php 
				global $wpdb;
				$sekolah = $wpdb->get_results("SELECT id_sekolah, nama_sekolah FROM `sekolah`");
				//print_r($sekolah->sekolah);
				?>
				<SELECT NAME="id_sekolah" ID="id_sekolah">
				  <OPTION VALUE=""></OPTION>
				<?php
				foreach ( $sekolah as $sekolah_detail ) 
				{
					echo "<OPTION VALUE=\"$sekolah_detail->id_sekolah;\" ". selected($sekolah->id_sekolah,$sekolah_detail->id_sekolah).">$sekolah_detail->nama_sekolah;</OPTION>";
				}
				?>
				</SELECT>	  
			  
				<br />
				<span class="description">Pilih Nama Sekolah ! </span>
				</select>
			  </td>
			  </tr>

			  </table><br>
			<input type=submit name=submit value=Update>&nbsp;&nbsp;
			<input type=reset name=reset value=Batal>
			<h3><a href="admin.php?page=<?=$_REQUEST['page']?>&crud=update">Kembali</a></h3>
			</form>

		<?
		}
	}
}